package fylder.chat;

import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;

import butterknife.Bind;
import fylder.chat.lib.KeyBoardBarDemo;
import fylder.chat.tools.ChatPictrueTools;

public class DemoActivity extends BaseAppCompatActivity implements IChatView, KeyBoardBarDemo.KeyBoardBarViewListener {

    @Bind(R.id.chat_lay)
    KeyBoardBarDemo chatLay;

    ChatPresenter presenter;

    @Override
    public int setLayoutView() {
        return R.layout.activity_demo;
    }

    @Override
    protected void initToolbar() {
        setToolText("哇啦啦", false, null);
    }

    @Override
    public void init() {
        chatLay.setOnKeyBoardBarViewListener(this);
        presenter = new ChatPresenter(this);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == Activity.RESULT_OK) {
            if (requestCode == ChatPictrueTools.CHOOSE_KIT_PICTURE) {
                //4.4以上相册回调     Uri
                presenter.resultPictureKit(data);
            } else if (requestCode == ChatPictrueTools.CHOOSE_BIG_PICTURE) {
                //4.4以下相册回调     Bitmap
                presenter.resultPicture(data);
            } else if (requestCode == ChatPictrueTools.CHOOSE_CAMERA) {
                //拍照    已保存图片
                presenter.resultCamera();
            }
        }
    }

    @Override
    public void clickSend() {

    }


    @Override
    public void OnKeyBoardStateChange(int state, int height) {

    }

    @Override
    public void onKeyBoardSendMsg(String msg) {
        presenter.sendMsg("msg:" + msg);
    }

    @Override
    public void onKeyBoardPhoto() {
        Toast.makeText(mContext, "select photo", Toast.LENGTH_SHORT).show();
        presenter.getPicture();
    }

    @Override
    public void onKeyBoardCamera() {
        Toast.makeText(mContext, "select camera", Toast.LENGTH_SHORT).show();
        presenter.getCamera();
    }

    @Override
    public void onKeyBoardVoice(String voiceFile) {
        Toast.makeText(mContext, voiceFile, Toast.LENGTH_SHORT).show();
        Log.w("123", voiceFile);
    }
}
